package designPattern.singleton;

public class DoubleCheckSingleton {

	private static int createTimes = 0;
	private static DoubleCheckSingleton instance;
	
	private int id ;
	
	private DoubleCheckSingleton() throws Exception{
		
          String test="";
          for(int i = 0; i < 10000; i++){
        	  test+=i;
          }
	}
	
	public static DoubleCheckSingleton getInstance() throws Exception{
		
		if(instance == null){
			
			synchronized(DoubleCheckSingleton.class){
			
				if(instance == null){
					instance =  new DoubleCheckSingleton();
					createTimes++;
					System.out.println(DoubleCheckSingleton.class.getName()+" create instance:"+createTimes+" times");
				}
			}
		}
		
		return instance;
	}
}
